import type { PageParams, PageResult } from '@/types/global'
import type { BannerItem, CategoryItem, GuessItem, HotItem } from '@/types/home'
import { http } from '@/utils/http'

// 首页-广告区域-小程序
// distributionSite
export const getHomeBannerAPI = (distributionSite = 1) => {
  return http<BannerItem[]>({
    method: 'GET',
    url: '/home/banner',
    data: {
      distributionSite,
    },
  })
}

// services/home.ts
/**
 * 首页-前台分类-小程序
 */

export const getHomeCategoryAPT = () => {
  return http<CategoryItem[]>({
    method: 'GET',
    url: '/home/category/mutli',
  })
}
// 首页-推荐
export const grtHomeHotAPI = () => {
  return http<HotItem[]>({
    method: 'GET',
    url: '/home/hot/mutli',
  })
}

/**
 * 猜你喜欢-
 *  (data?: PageParams) ?代表可传可不传入的意思
 */
export const getHomeGoodsGuessLikeAPI = (data?: PageParams) => {
  //<PageResult<GuessItem>> 代表的是PageResult类型的item是泛型，通过传入GuessItem来确认item类型
  return http<PageResult<GuessItem>>({
    method: 'GET',
    url: '/home/goods/guessLike',
    data,
  })
}
